<script setup lang="ts">
import { defineEmits, defineProps, withDefaults } from 'vue';

// 定义 Props 接口
interface Props {
  title?: string; // 可选
}

// 用 withDefaults 同时完成类型声明与默认值
const props = withDefaults(defineProps<Props>(), {
  title: '' // 默认空字符串，避免“requires default” :contentReference[oaicite:2]{index=2}
});

// 发射事件
// eslint-disable-next-line vue/define-emits-declaration
const emit = defineEmits(['calculate', 'report']);
function onCalculate() {
  emit('calculate');
}
function onReport() {
  emit('report');
}
</script>

<template>
  <div class="form-wrapper">
    <h2>{{ props.title }}</h2>
    <slot></slot>
    <div class="actions">
      <NButton type="primary" @click="onCalculate">计算</NButton>
      <NButton type="success" @click="onReport">生成报告</NButton>
    </div>
  </div>
</template>
